// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: xpath_result.hpp 210 2008-08-28 10:10:41Z heavyzheng $
//

#ifndef ZZHENG_XML_DOM_LIBXML2_XPATH_RESULT_HPP_20080722__
#define ZZHENG_XML_DOM_LIBXML2_XPATH_RESULT_HPP_20080722__

#include <zzheng/xml/config.hpp>
#include <zzheng/xml/dom/types.hpp>
#include <zzheng/xml/dom/basic_node_ptr.hpp>
#include <zzheng/xml/dom/libxml2/node.hpp>
#include <zzheng/xml/dom/libxml2/node_set.hpp>
#include <zzheng/xml/dom/libxml2/libxml2_fwd.hpp>

#include <boost/shared_ptr.hpp>
#include <string>

namespace zzheng {
namespace xml {
namespace dom {
namespace libxml2_ {

    class xpath;

    //! This class represents a result evaluated from an XPath expression. An XPath result may be a
    //! boolean, a number, a string or a node set.
    class xpath_result {

        friend class xpath; // Friend class declaration.

    public:

        //! Default constructor. Constructs an empty XPath result.
        explicit xpath_result();

        // Use auto-generated copy constructor.
        // Use auto-generated copy assignment.
        // Use auto-generated destructor.

        //! Returns the type of this XPath result.
        //! \return the type of this XPath result.
        xpath_result_t type() const;

        //! Returns the boolean value of this XPath result.
        bool as_boolean() const;

        //! Returns the number value of this XPath result.
        int as_number() const;

        //! Returns the string value of this XPath result.
        std::string as_string() const;

        //! Returns the node set value of this XPath result.
        node_set& as_node_set();

        //! Const version of as_node_set().
        const node_set& as_node_set() const;

    private:

        void set(xmlXPathObject* px);

    private:

        boost::shared_ptr<xmlXPathObject> raw_;      //!< Raw pointer to an xmlXPathObject.
        node_set                          node_set_; //!< Wrapper to the node set.

    }; // class xpath_result

} // namespace zzheng::xml::dom::libxml2_
} // namespace zzheng::xml::dom
} // namespace zzheng::xml
} // namespace zzheng

#endif // ZZHENG_XML_DOM_LIBXML2_XPATH_RESULT_HPP_20080722__



